package com.example.nettyparseinner.future;

import io.netty.channel.EventLoop;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.concurrent.DefaultPromise;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * author :sherlock.lin
 * date : Created in 2023/2/9
 * description :
 */
public class TestNettyPromise {
    private static final Logger LOG = LoggerFactory.getLogger(TestNettyPromise.class);

    public static void main(String[] args) throws Exception{
        EventLoop eventLoop = new NioEventLoopGroup().next();
        DefaultPromise<Integer> promise = new DefaultPromise<>(eventLoop);

        new Thread(()->{
            LOG.debug("开始计算....");
            try{
                Thread.sleep(1000);
            }catch (InterruptedException e) {
                e.printStackTrace();
            }
            promise.setSuccess(8080);
        }).start();

        LOG.debug("等待结果...");
        LOG.debug("结果是:{}", promise.get());
    }

}
